package com.example.service.impl;

import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.example.entity.Doctor;
import com.example.entity.User;
import com.example.entity.req.Page;
import com.example.mapper.DoctorMapper;
import com.example.service.DoctorService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DoctorServiceImpl implements DoctorService {

    @Autowired
    DoctorMapper doctorMapper;

    @Override
    public void insert(Doctor record) {
        doctorMapper.insert(record);
    }

    @Override
    public PageInfo<Doctor> pageDoctor(Page page) {
        PageHelper.startPage(page.getPageNum(), page.getPageSize());
        List<Doctor> userInfoList = new LambdaQueryChainWrapper<Doctor>(doctorMapper).list();
        PageInfo<Doctor> pageInfo = new PageInfo<>(userInfoList);
        return pageInfo;
    }

    @Override
    public void del(Integer id) {
        doctorMapper.deleteById(id);
    }
}
